
import os
import curses
from build.process import BuildSystem
from build.config import BuildConfig

def start():
    bs = BuildSystem()
    str = bs.start_screen()
    print("str %s" % str)

    bc = BuildConfig("tools/nbuild.cfg")
    print("bc confs", bc.confs)
    cmd = bs.build_progs(bc.confs)
    if cmd == None:
        bs.close()
        return None

    print("next command %s" % cmd)

    bs.start_build(cmd)

    bs.close()

    return cmd

def real_build(progs):
    progs_str = ""
    for prog in progs:
        progs_str = progs_str + " " + prog

    cmdstr = "CUSTOM_LIBS=\"" + progs_str + "\" ./tools/build.sh "
    print("build with %s " % cmdstr)
    os.system(cmdstr)

if __name__ == "__main__":
    cmds = start()
    if cmds != None:
        real_build(cmds)
    else:
        print("You choose nothing, exit")
